#include "gamehall.h"
#include "ui_gamehall.h"

#include<QPainter>
#include<QPixmap>
#include<QIcon>
#include<QPushButton>
#include<QFont>
#include<gameselect.h>
#include<QSound>

GameHall::GameHall(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::GameHall)
{
    ui->setupUi(this);

    this->setFixedSize(1000,800);//设置窗口大小
    this->setWindowIcon(QIcon(":res/ico.png"));//设置窗口图标
    this->setWindowTitle("贪吃蛇游戏");//设置窗口标题

    QFont font("华文行楷",24);
    QPushButton *strbtn = new QPushButton(this);
    strbtn->move(430,530);
    strbtn->setFont(font);
    strbtn->setText("开始游戏");
    strbtn->setStyleSheet("QPushButton{border:0px;}");

    GameSelect *gameSelect = new GameSelect();
    connect(strbtn,&QPushButton::clicked,[=](){
        this->close();
        gameSelect->setGeometry(this->geometry());
        gameSelect->show();

        QSound::play(":res/clicked.wav");
    });


}

GameHall::~GameHall()
{
    delete ui;
}

void GameHall::paintEvent(QPaintEvent *event)
{
    //实例化画家对象
    QPainter painter(this);

    //QPixmap实例化绘图设备
    QPixmap pix(":res/game_hall.png");

    //画家在绘画
    painter.drawPixmap(0,0,this->width(),this->height(),pix);

}



